package tcp;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class TesteServerSocket2 extends Thread {

    private ServerSocket sock;

    public TesteServerSocket2() {
        try {
            sock = new ServerSocket(4413);
            System.out.println("Servidor rodando!");
        } catch (IOException e) {
            System.out.println("Erro: N�o pode criar o Socket");
        }
    }

    public void run() {
        Socket client = null;

        while (true) {
            if (sock == null) {
                return;
            }
            try {
                client = sock.accept();

                NovaThread novaThread = new NovaThread(client);
                novaThread.start();
            } catch (Exception e) {
                System.out.println("Erro: N�o pode se conectar ao cliente!");
            }
        }
    }

    public static void main(String[] args) {
        TesteServerSocket2 server = new TesteServerSocket2();
        server.start();
    }
}
